package com.ruoyi.web.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RoutePlanning;
import com.ruoyi.system.service.IRoutePlanningService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 路径规划Controller
 * 
 * @author ruoyi
 * @date 2024-09-24
 */
@RestController
@RequestMapping("/system/RoutePlanning")
public class RoutePlanningController extends BaseController
{
    @Autowired
    private IRoutePlanningService routePlanningService;

    /**
     * 查询路径规划列表
     */
    @PreAuthorize("@ss.hasPermi('system:RoutePlanning:list')")
    @GetMapping("/list")
    public TableDataInfo list(RoutePlanning routePlanning)
    {
        startPage();
        List<RoutePlanning> list = routePlanningService.selectRoutePlanningList(routePlanning);
        return getDataTable(list);
    }

    /**
     * 导出路径规划列表
     */
    @PreAuthorize("@ss.hasPermi('system:RoutePlanning:export')")
    @Log(title = "路径规划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RoutePlanning routePlanning)
    {
        List<RoutePlanning> list = routePlanningService.selectRoutePlanningList(routePlanning);
        ExcelUtil<RoutePlanning> util = new ExcelUtil<RoutePlanning>(RoutePlanning.class);
        util.exportExcel(response, list, "路径规划数据");
    }

    /**
     * 获取路径规划详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:RoutePlanning:query')")
    @GetMapping(value = "/{routeId}")
    public AjaxResult getInfo(@PathVariable("routeId") Long routeId)
    {
        return success(routePlanningService.selectRoutePlanningByRouteId(routeId));
    }

    /**
     * 新增路径规划
     */
    @PreAuthorize("@ss.hasPermi('system:RoutePlanning:add')")
    @Log(title = "路径规划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RoutePlanning routePlanning)
    {
        return toAjax(routePlanningService.insertRoutePlanning(routePlanning));
    }

    /**
     * 修改路径规划
     */
    @PreAuthorize("@ss.hasPermi('system:RoutePlanning:edit')")
    @Log(title = "路径规划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RoutePlanning routePlanning)
    {
        return toAjax(routePlanningService.updateRoutePlanning(routePlanning));
    }

    /**
     * 删除路径规划
     */
    @PreAuthorize("@ss.hasPermi('system:RoutePlanning:remove')")
    @Log(title = "路径规划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{routeIds}")
    public AjaxResult remove(@PathVariable Long[] routeIds)
    {
        return toAjax(routePlanningService.deleteRoutePlanningByRouteIds(routeIds));
    }
}
